/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package dreamwar.controller;

import dreamwar.model.POJO.Army;
import dreamwar.model.POJO.Feature;
import dreamwar.view.ArmyListPanel;
import dreamwar.view.LoginFrame;
import dreamwar.view.MainFrame;
import dreamwar.view.ModifyArmyPanel;
import dreamwar.view.ModifyFeaturePanel;
import java.awt.CardLayout;
import java.util.List;
import javax.swing.JPanel;

/**
 *
 * @author Berto_Romero
 */
public class GUIController {
    
    public static final String ARMY_LIST_PANEL = "armyListPanel";
    public static final String CREATE_ARMY_PANEL = "createArmyPanel";
    public static final String MODIFY_ARMY_PANEL = "modifyArmyPanel";
    public static final String FEATURE_LIST_PANEL = "featureListPanel";
    public static final String CREATE_FEATURE_PANEL = "createFeaturePanel";
    public static final String MODIFY_FEATURE_PANEL = "modifyFeaturePanel";
    
    private static GUIController gUIController = null;
    private ArmyListPanel armyListPanel = null;
    private LoginFrame loginFrame = null;
    private MainFrame mainFrame = null;
    private ModifyArmyPanel modifyArmyPanel = null;

    private GUIController() {
    }
    
    public static GUIController getInstance() {
        if (gUIController == null) {
            gUIController = new GUIController();
        }
        return gUIController;
    }

    public void setArmyListPanel(ArmyListPanel armyListPanel) {
        this.armyListPanel = armyListPanel;
    }

    public void setLoginFrame(LoginFrame loginFrame) {
        this.loginFrame = loginFrame;
    }

    public void setMainFrame(MainFrame mainFrame) {
        this.mainFrame = mainFrame;
    }

    public void setModifyArmyPanel(ModifyArmyPanel modifyArmyPanel) {
        this.modifyArmyPanel = modifyArmyPanel;
    }
    
    public void showLoginFrame() {
        LoginFrame.main(null);
    }
    
    public void showMainFrame() {
        MainFrame.main(null);
    }
    
    public void changeMainFrameCard(String cardName) {
        mainFrame.changeCard(cardName);
    }
    
    public void prepareModifyArmyPanel(List<Army> armyList) {
        modifyArmyPanel.addArmyBays(armyList);
    }
    
    public void createArmy(Army army) {
        armyListPanel.createArmy(army);
    }
    
    public void createArmy(int index, Army army) {
        armyListPanel.createArmy(index, army);
    }
    
    
    
    
    
    
    
    
    
    
    
    private JPanel mainJPanel = null;
    private ModifyArmyPanel modifyArmyJPanel = null;
    private ModifyFeaturePanel modifyFeatureJPanel = null;

    public void setMainJPanel(JPanel jPanel) {
        mainJPanel = jPanel;
    }
    
    public void setModifyArmyJPanel(ModifyArmyPanel modifyArmyJPanel) {
        this.modifyArmyJPanel = modifyArmyJPanel;
    }

    public void setModifyFeatureJPanel(ModifyFeaturePanel modifyFeatureJPanel) {
        this.modifyFeatureJPanel = modifyFeatureJPanel;
    }
    
    public void changeMainJFrameCard(String cardName) {
        CardLayout cl = (CardLayout) (mainJPanel.getLayout());
        cl.show(mainJPanel, cardName);
    }
    
    public void prepareModifyFeatureJPanel(Feature feature) {
        modifyFeatureJPanel.setFields(feature);
    }
}
